﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class status
    {
        public static dynamic inquiryBackupCode(string username, bool allDate, DateTime? dateBegin, DateTime? dateEnd)
        {
            var sql = new Sql.SqlDataContext();
            var ss = sql.Status.Where(row => !row.god && row.status == 3 && row.username.ToLower() == username.ToLower());
            if (!allDate) ss = ss.Where(row => row.submitTime >= dateBegin && row.submitTime < dateEnd);
            var accept = ss.Count();
            var problemAccept = ss.GroupBy(row => row.pid).Count();
            return new
            {
                success = true,
                accept,
                problemAccept
            };
        }
    }
}
